<template>
  <el-popconfirm
    :title="tipMsg"
    @on-confirm="click"
    @confirm="click"
    class="anvil-button anvil-button-text-edit"
  >
    <template #reference>
      <el-button
        size="small"
        type="primary"
        link
        icon="Refresh"
        v-hasPermi="perm"
        v-hasRole="role"
        v-hasRoleType="roleType"
      >{{ text }}</el-button
      >
    </template>
  </el-popconfirm>
</template>

<script>
export default {
  name: 'TextResetButton',
  inheritAttrs: false,
  props: {
    text: {
      type: String,
      required: false,
      default: () => '重置'
    },
    title: {
      type: String,
      required: false,
      default: () => '是否确认重置？'
    },
    subject: {
      type: String,
      required: false,
      default: () => ''
    },
    perm: {
      type: Array,
      required: false,
      default: () => []
    },
    role: {
      type: Array,
      required: false,
      default: () => []
    },
    roleType: {
      type: Array,
      required: false,
      default: () => []
    }
  },
  computed: {
    tipMsg: function () {
      return (
        this.title || '是否确认' + this.text + (this.subject ? '[' + this.subject + ']' : '') + '?'
      )
    }
  },
  methods: {
    click() {
      this.$emit('click')
    }
  }
}
</script>
